package com.firewolf.word;

import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.firewolf.utils.FreeMarkerUtil;

import freemarker.template.Template;
import freemarker.template.TemplateException;

/**
 * 数据类型
 * 
 * @author liuxing
 *
 */
public class Excel {
	public static void main(String[] args) throws TemplateException,
			IOException {
		// 数据模型
		Map<String, Object> root = new HashMap<>();
		List<Student> sList = new ArrayList<>();
		sList.add(new Student("华中农业", "张三", "45", "男"));
		sList.add(new Student("华中师范", "李四", "65", "男"));
		sList.add(new Student("华中科技", "王五", "35", "女"));
		root.put("stus", sList);

		Template tl = FreeMarkerUtil.getTemplate("stu.ftl");

		Writer w = new FileWriter("test.xlsx");// 把数据显示到控制台
		tl.process(root, w);
		w.flush();
	}
}
